package com.mega.fe.mixins;

import com.mega.fe.item.FantasyEnding;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import javax.annotation.Nullable;

@Mixin(ItemStack.class)
public abstract class ItemStackMixin {

    @Shadow
    @Final
    @Deprecated
    @Nullable
    private Item item;

    @Inject(method = "isEmpty", at = @At("HEAD"), cancellable = true)
    private void isEmpty(CallbackInfoReturnable<Boolean> cir) {
        if (item instanceof FantasyEnding)
            cir.setReturnValue(false);
    }

    @Inject(method = "getCount", at = @At("HEAD"), cancellable = true)
    private void getCount(CallbackInfoReturnable<Integer> cir) {
        if (item instanceof FantasyEnding)
            cir.setReturnValue(1);
    }
}
